Electronic device with calibrated compass

ABSTRACT

An electronic device may have electrical components mounted in alignment with an electronic device housing. A compass in the electronic device housing may potentially be misaligned with respect to the electrical components and the electronic device housing. Reference devices having compasses may be used to gather compass data while one or more electrical components in the reference devices are controlled to generate magnetic fields that are detected by the compasses. An electronic device may be calibrated in a factory or in the field using calibration data produced by comparing compass readings gathered from the compass in the device while controlling electrical components in the device to compass data from the reference devices. Calibration data may be applied to compass readings in real time to correct for misalignment between the compass and the electronic device housing.

This application is a continuation of U.S. patent application Ser. No.14/322,734, filed Jul. 2, 2014, which claims the benefit of U.S.provisional patent application No. 61/883,599, filed Sep. 27, 2013. Thisapplication claims the benefit of and claims priority to U.S. patentapplication Ser. No. 14/322,734, filed Jul. 2, 2014, and U.S.provisional patent application No. 61/883,599, filed Sep. 27, 2013,which are hereby incorporated by reference herein in their entireties.

BACKGROUND

This relates generally to electronic devices and, more particularly, toelectronic devices with compasses.

Electronic devices are sometimes provided with compasses. For example, ahandheld Global Positioning System (GPS) device or cellular telephonemay have a compass. Compass readings from the compass may be used forfunctions such as ensuring that maps are oriented correctly whendisplayed for a user.

Satisfactory compass performance is dependent on accurate alignment ofthe compass. If care is not taken, a compass may be misaligned withrespect to the device in which it is housed and the resulting readingsproduced by the compass will be inaccurate. During manufacturing,devices that contain compasses are sometimes subjected to coarse“pass-fail” testing by passing the devices through a fixed magneticfield. If the compass in a device does not respond to the appliedmagnetic field, the device will not pass testing. Such coarse pass-failtesting is not, however, able to address whether or not the compass isproperly aligned within a device.

It would therefore be desirable to provide improved ways to ensure thatelectronic devices with compasses will perform satisfactorily.

SUMMARY

An electronic device may have electrical components mounted in alignmentwith an electronic device housing. The electrical components may includecomponents such as a camera with an adjustable focus, a camera flash,and a radio-frequency transceiver. Components such as these may drawsufficient current during operation to generate magnetic fields in thevicinity of a compass within the electronic device.

The electrical components may be mounted on a substrate such as a rigidprinted circuit board. The rigid printed circuit board may be wellaligned with respect to the electronic device housing. The compass inthe electronic device housing may be mounted on a flexible printedcircuit that is coupled to the printed circuit board. Due to normalmanufacturing variations or due to a drop event, there is a potentialfor misalignment between the compass and the electronic device housing.During operation of the electronic device, control circuitry in theelectronic device can apply calibration data to compass readings fromthe compass. The control circuitry may, for example, apply a calibrationrotation matrix to raw compass data. The calibration data may correctcompass readings from the compass for misalignment between the compassand the electronic device housing.

Reference devices may be used in gathering compass data. The referencedevices may have compasses that are aligned with respect to theirhousings or that are in a known orientation with respect to theirhousings. Compass data may be acquired within the reference deviceswhile electrical components in those devices that are aligned withrespect to the housings of the reference devices are controlled togenerate magnetic fields. Device-specific compass calibration data maybe produced by comparing compass readings from a device to be calibratedto compass readings associated with the reference devices. Both thecompass readings from the reference devices and the compass readingsfrom the device to be calibrated are preferably obtained while using thesame set of operating conditions for the electronic components thatproduce the magnetic fields. An electronic device may be calibrated in afactory or in the field using the calibration data.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a perspective view of an illustrative electronic device suchas a handheld computing device of the type that may be provided with acompass in accordance with an embodiment.

FIG. 2 is a schematic diagram of an illustrative electronic device witha compass in accordance with an embodiment.

FIG. 3 is a cross-sectional side view of printed circuits that may bepopulated with electronic components such as integrated circuits and acompass in an electronic device in accordance with an embodiment.

FIG. 4 is a top interior view of an illustrative electronic devicehaving electrical components on a rigid printed circuit board mounted toan electronic device housing and having a printed circuit with a compassthat is coupled to the rigid printed circuit board in accordance with anembodiment.

FIG. 5 is a graph showing illustrative compass measurements that may bemade while simultaneously adjusting the operation of electricalcomponents in an electronic device in accordance with an embodiment.

FIG. 6 is a flow chart of illustrative operations involved incalibrating and operating an electronic device with a compass inaccordance with an embodiment.

DETAILED DESCRIPTION

An electronic device may be provided with a compass. The compass may beused to gather compass readings (orientation data). The compass readingsare indicative of how the compass is oriented. Electrical componentswithin the device may be used to generate magnetic fields that are usedin calibrating the compass. Calibration operations may be performed aspart of a manufacturing process and during normal operation of anelectronic device in the field by a user.

An illustrative electronic device of the type that may be provided withcompass is shown in FIG. 1. Electronic device 10 of FIG. 1 may be acomputing device such as a laptop computer, a computer monitorcontaining an embedded computer, a tablet computer, a cellulartelephone, a media player, or other handheld or portable electronicdevice, a smaller device such as a wrist-watch device, a pendant device,a headphone or earpiece device, or other wearable or miniature device, atelevision, a computer display that does not contain an embeddedcomputer, a gaming device, a navigation device, an embedded system suchas a system mounted in a kiosk or automobile, equipment that implementsthe functionality of two or more of these devices, or other electronicequipment. In the illustrative configuration of FIG. 1, device 10 is aportable device such as a cellular telephone, media player, tabletcomputer, or other portable computing device. Other configurations maybe used for device 10 if desired. The example of FIG. 1 is merelyillustrative.

Device 10 may have one or more displays such as display 14 mounted inhousing structures such as housing 12. Housing 12 of device 10, which issometimes referred to as a case, may be formed of materials such asplastic, glass, ceramics, carbon-fiber composites and other fiber-basedcomposites, metal (e.g., machined aluminum, stainless steel, or othermetals), other materials, or a combination of these materials. Device 10may be formed using a unibody construction in which most or all ofhousing 12 is formed from a single structural element (e.g., a piece ofmachined metal or a piece of molded plastic) or may be formed frommultiple housing structures (e.g., outer housing structures that havebeen mounted to internal frame elements or other internal housingstructures).

Display 14 may be a touch sensitive display that includes a touch sensoror may be insensitive to touch. Touch sensors for display 14 may beformed from an array of capacitive touch sensor electrodes, a resistivetouch array, touch sensor structures based on acoustic touch, opticaltouch, or force-based touch technologies, or other suitable touch sensorcomponents.

Display 14 for device 10 includes display pixels formed from liquidcrystal display (LCD) components or other suitable display pixelstructures such as organic light-emitting diode display pixels,electrophoretic display pixels, plasma display pixels, etc. A displaycover layer may cover the surface of display 14 or a display layer suchas a color filter layer (e.g., a layer formed from a clear substratecovered with patterned color filter elements) or other portion of adisplay may be used as the outermost (or nearly outermost) layer indisplay 14. If desired, openings may be formed in the outermost layer ofdisplay 14 to accommodate components such as button 16 and speaker port18.

A schematic diagram of an illustrative configuration that may be usedfor electronic device 10 is shown in FIG. 2. As shown in FIG. 2,electronic device 10 may include control circuitry 22. Control circuitry22 may include storage and processing circuitry for controlling theoperation of device 10. Control circuitry 22 may, for example, includestorage such as hard disk drive storage, nonvolatile memory (e.g., flashmemory or other electrically-programmable-read-only memory configured toform a solid state drive), volatile memory (e.g., static or dynamicrandom-access-memory), etc. Control circuitry 22 may include processingcircuitry based on one or more microprocessors, microcontrollers,digital signal processors, baseband processors, power management units,audio codec chips, application specific integrated circuits, etc.

Input-output devices 24 may be used to allow data to be supplied todevice 10 and to allow data to be provided from device 10 to externaldevices. Input-output devices 24 may also include input-outputcomponents with which a user can control the operation of device 10. Auser may, for example, supply commands through input-output devices 24and may receive status information and other output from device 10 usingthe output resources of input-output devices 24.

Input-output devices 24 may include sensors and status indicators suchas an ambient light sensor, a proximity sensor, a temperature sensor, apressure sensor, an accelerometer, and light-emitting diodes and othercomponents for gathering information about the environment in whichdevice 10 is operating and providing information to a user of device 10about the status of device 10. Compass 26 may be used to determine theorientation of device 10 in space relative to the Earth's magnetic pole.Compass readings may be used to orient maps on display 14, may be usedto assist in navigation operations, and may be used by otherapplications running on device 10. Audio components in devices 24 mayinclude speakers and tone generators for presenting sound to a user ofdevice 10 and microphones for gathering user audio input. Devices 24 mayinclude one or more displays such as display 14 of FIG. 1. Displays maybe used to present images for a user such as text, video, and stillimages. Sensors in devices 24 may include a touch sensor array that isformed as one of the layers in display 14. During operation, user inputmay be gathered using buttons and other input-output components indevices 24 such as touch pad sensors, buttons, joysticks, click wheels,scrolling wheels, touch sensors such as a touch sensor array in a touchscreen display or a touch pad, key pads, keyboards, vibrators, and otherinput-output components.

Input-output devices 24 may use one or more cameras such as camera 28 toacquire digital images. Camera flash 30 may provide subject illuminationfor images being acquired by camera 28. Camera flash 30 may be based onone or more light-emitting diodes or other light sources.

Input-output devices 24 may include wireless communications circuitrysuch as radio-frequency transceiver 32 and one or more antennas.Transceiver circuitry 32 may be formed from one or more integratedcircuits and may be coupled to the antennas of device 10 through poweramplifier circuitry, low-noise input amplifiers, passive RF components,or other circuitry. A baseband processor integrated circuit (e.g., anintegrated circuit in control circuitry 22) may be used to providetransceiver 32 with signals that are to be wirelessly transmitted bydevice 10 and may be used to process signals that transceiver 32 hasreceived using antenna structures in device 10.

Power may be supplied to input-output devices 24 and control circuitry22 using battery 34 and other sources of power. Power management unit 36(e.g., one or more integrated circuits) may be used in regulating powerdelivery from battery 34 and other sources of power. The electricalcomponents of device 10 (e.g., compass 26, camera 28, flash 30,radio-frequency transceiver circuitry 32, and other input-output devices24, integrated circuits in control circuitry 22, power management unit36, and battery 34 may be interconnected within device 10 using signallines on printed circuits, wires, coaxial cables and other transmissionlines, and other signal paths. For example, electrical components may beinterconnected using signal lines formed from metal traces on printedcircuits such as rigid printed circuit boards (e.g., printed circuitsformed from fiberglass-filled epoxy or other rigid printed circuit boardmaterial) or flexible printed circuits (e.g., flex circuits formed fromsheets of polyimide or layers of other flexible polymer). Printedcircuits may be joined using solder joints, connectors, conductiveadhesive connections, or other conductive connections.

FIG. 3 is a cross-sectional side view of illustrative printed circuitsand electrical components of the type that may be used in electronicdevice 10. As shown in FIG. 3, device 10 may include compass 26. Compass26 may be formed from a Hall effect sensor, a microelectromechanicalsystems (MEMS) compass, or other magnetic sensor for gatheringinformation on the presence of magnetic fields (i.e., the Earth'smagnetic field). Compass 26 may be mounted on printed circuit 42.Compass 26 may, for example, have contacts 44 that are soldered tosolder pads 46 and other traces 48 in printed circuit 42 using solder46. Traces 48 may be metal signal lines formed from metals such ascopper, aluminum, molybdenum, other metals, and combinations of thesemetals.

Conductive connections 50 may be used in coupling printed circuit 42 toone or more other printed circuits such as printed circuit board 40. Forexample, connections 50 may be used to electrically couple traces 48 inprinted circuit 42 to traces 52 in printed circuit 40. Connections 50may be formed from solder, conductive adhesive, connectors, etc.

Traces 52 may be used to interconnect electrical components such ascomponents 54 and 56. Components 54 and 56 may have contacts 58 that aresoldered to solder pads 62 in traces 52 on printed circuit 40 usingsolder 60. Traces 52 may include metal signals lines formed from metalssuch as copper, aluminum, molybdenum, other metals, and combinations ofthese metals.

Printed circuits such as printed circuits 40 and 42 may be rigid printedcircuit boards, rigid flex (e.g., rigid printed circuit boards withintegral flex circuit tails), or flexible printed circuits. As anexample, printed circuit 42 may be a flexible printed circuit andprinted circuit 40 may be a rigid printed circuit board. Two printedcircuits are shown in FIG. 3, but, in general, any suitable number ofprinted circuits may be coupled together if desired within device 10(e.g., two printed circuits, three or more printed circuits, four ormore printed circuits, etc.). Each printed circuit may be coupled to oneor more electrical components such as integrated circuits, a camera(e.g., a digital image sensor such as camera 28), a camera flash such ascamera flash 30, a radio-frequency transceiver circuit such astransceiver 32 of FIG. 2 (e.g., a wireless local area networktransceiver such as an 802.11 transceiver operating at 2.4 GHz and/or 5GHz, a cellular telephone transceiver circuit, a Bluetooth® transceiver,or other wireless transceiver circuitry), or other electricalcomponents.

Components 54 and 56 and compass 26 may send and receive signals (e.g.,power and/or data signals) over signal paths in printed circuits 40 and42. For example, control circuitry 22 (e.g., control circuitryimplemented using one or more integrated circuits or other electricalcomponents mounted on printed circuit 40) may issue control signals oversignal lines such as signal lines 52 and/or 48 that direct an electricalcomponent to operate in a particular way. These signals may, forexample, adjust the position of a focusing element in camera 28, mayturn on flash 30, or may activate or otherwise adjust the operation ofradio-frequency transceiver circuitry 32.

As electrical components 54 and 56 on board 40 are being controlled bycontrol signals issued by control circuitry 22 (i.e., as the operatingsettings of one or more components are being adjusted), the electricalcomponents will draw power. Power management unit 36 (FIG. 2) may supplypower to the electrical components over signal paths 52. The amount ofpower that is being delivered to each electrical component varies inresponse to the control signals. As an example, when control circuitry22 directs component 56 to operate in a first way that requires a firstamount of power delivery to component 56, component 54 (e.g., a powermanagement unit) may supply a first amount of power over path 52,whereas when control circuitry 22 directs component 56 to operate in asecond way that requires a second amount of power delivery to component56, component 54 (e.g., a power management unit) may supply a secondamount of power over path 52.

As power is being delivered from component 54 to component 56, a currentthat is proportional to the amount of power that is being delivered willflow in the power supply line (e.g., in signal line segment 52′ in theexample of FIG. 3). This current will, in turn, generate magnetic fieldssuch as magnetic field 64. Compass 26 is sensitive to the presence ofmagnetic fields, and will therefore be affected by the presence ofmagnetic field 64.

During normal operation of device 10 in the field by a user, compass 26can acquire compass readings during periods of time when potentiallyinterfering electronic components are not being actively used and/or canbe calibrated to compensate for the presence of magnetic fields such asmagnetic field 64. For example, if it is determined that operation of anelectromagnetic actuator such as a lens focusing coil in camera 28produces a particular interfering magnetic field 64 (through operationof the coil and/or as a result of current flow through paths such aspath segment 52′) during operation of camera 28, use of camera 28 can beavoided when making compass readings with compass 26 and/or the impactof the magnetic field that arises from operating camera 28 can bequantified in advance so that compass readings can later be adjusted bysubtracting out the magnetic field contribution from camera 28.

Calibration operations may also be performed to compensate for potentialmisalignment of compass 26 relative to housing 12. Misalignment betweencompass 26 and electronic device housing 12 in device 10 may be due tofactors such as misalignment of compass 26 relative to the printedcircuit to which compass 26 is mounted or misalignment of the printedcircuit to which compass 26 is mounted relative to housing 12.

Consider, as an example, the illustrative configuration of device 10that is shown in FIG. 4. FIG. 4 is an interior view of an electronicdevice such as device 10 of FIG. 1 in which display 14 has been removedfrom the front face of the device to reveal interior components. Asshown in FIG. 4, device to may have housing 12. Housing 12 may be formedfrom materials such as metal, plastic, carbon-fiber composite and otherfiber-composite material, glass, ceramic, or other materials. Printedcircuits such as printed circuit 40 and printed circuit 42 may bemounted in device housing 12. Electrical components such as camera 28,flash 30, radio-frequency transceiver 32, power management unit 36,control circuitry 22 such as baseband processor 22′ and other storageand processing circuitry, compass 26, and other electrical componentsmay be mounted on the printed circuits. Battery 34 may be coupled topower management unit 36 by paths 52 and terminals 74. Paths 52 may alsobe used in interconnecting other electrical components on printedcircuit board 40.

Compass 26 may be formed from a Hall effect sensor, a MEMS device, orother electrical component for measuring the Earth's magnetic field.Compass 26 may be sensitive to stresses within the printed circuit towhich it is mounted. It may be desirable to mount printed circuits indevice 10 to device housing 12 using fasteners such as screws. Forexample, printed circuit 40 may be a rigid printed circuit board that isattached to housing 12 using screws 70. The presence of screws 70 andthe presence of heat fluctuations generated by the components mounted toprinted circuit board 40 may give rise to stresses on the electricalcomponents mounted on printed circuit board 40.

The presence of printed circuit board stress may make it difficult for acompass such as a compass based on Hall effect sensors that is mountedon the printed circuit board to make accurate compass readings. It maytherefore be desirable to locate compass 26 on a printed circuit that isseparate from printed circuit 40 such as printed circuit 42 of FIG. 4.Printed circuit 42 may be, for example, a flexible printed circuit.

As shown in FIG. 4, flexible printed circuit 42 may be coupled to rigidprinted circuit board 40 using connections 50. Connections 50 may beconductive adhesive connections, connections formed from solder joints,or other connections.

Due to manufacturing variations, the placement of structures in devices10 during manufacturing can vary from device to device. Some structurescan be placed with high accuracy. For example, rigid printed circuitboards that are attached directly to housing 12 such as printed circuitboard 40 will generally be accurately aligned with respect to housing 12during assembly operations (e.g., when attaching printed circuit board40 to housing 12 with screws 70). Other manufacturing operations aremore prone to placement errors. For example, the process of attachingflexible printed circuit 42 to printed circuit 40 using connections 50and the process of soldering or otherwise attaching compass 26 onflexible printed circuit 42 may be subject to lateral placementvariations and angular placement variations. These variations may giverise to uncertainty in the orientation of compass 26 relative to housing12. For example, there may be uncertainty in angular orientation A ofcompass 26 in the plane of device 10 relative to housing 12 that arisesfrom uncertainty in the angular orientation of compass 26 relative toflexible printed circuit 42 and angular uncertainty of the angularorientation of flexible printed circuit 42 to printed circuit board 40following formation of electrical connections 50.

Uncertainty in the position of compass 26 relative to device 10 andhousing 12 can degrade compass performance. For example, a user ofdevice 10 may desire to use a navigation application or otherapplication in which device housing 12 displays an on-screen map that isoriented in a particular direction based on compass readings or maydesire to use an application that presents an on-screen representationof a compass to a user. Accurate orientation of the on-screen map oron-screen compass depends on the accuracy of the compass readingsrelative to the position of the housing. If, for example, compass 26 ismisaligned with respect to flexible printed circuit 42 and/or flexibleprinted circuit 42 is misaligned with respect to housing 12 and otherstructures mounted to housing 12 such as board 40 and display 14, thereis a potential for corresponding alignment errors in the on-screencontent that depends on readings from the compass.

Printed circuit board 40 may be accurately aligned with respect sohousing 12 using screws 70. However,flexible-printed-circuit-to-printed-circuit-board coupling arrangementssuch as connections 50 may allow flexible printed circuit 42 to bemisaligned with respect to board 40 (and therefore with respect tohousing 12) by up to 5° or 10° or more. In addition, misalignment of upto 5° or more is possible when using solder joints or other conductiveattachment mechanisms to mount compass 26 to flexible printed circuit42. Compass misalignment with respect to electronic device housing 12may also arise when device 10 is inadvertently exposed to shock (e.g.,during a drop event). Because of these possible sources of misalignmentduring manufacturing, it is possible that compass 26 will be misalignedby an angle A of up to 5 to 10° or more with respect to housing 12(i.e., horizontal axis 72) unless corrective action is taken. This canlead to on-screen map alignment errors or other misalignment problems of5 to 10° or more.

The effects of misalignment angle A due to manufacturing variations canbe removed using calibration operations. The position of printed circuitboard 40 relative to housing 12 is well known due to the use of screws70 and/or other accurate mounting structures. As a result, the positionsof signal paths 52 on board 40 and the orientations of the magneticfields 64 relative to compass 26 that are produced by currents flowingthrough paths 52 and through the structures of the electrical componentson printed circuit board 40 can be accurately characterized. Duringprecalibration operations, the response of compasses with one or moreknown orientations relative to housing 12 can be characterized in thepresence of magnetic fields 64 that are detected by the compasses. Usingthe characterized behavior of compass 26 to magnetic fields 64 under avariety of conditions, compass 26 in a given device can be calibrated(i.e., device-specific calibration data can be produced and stored inmemory in control circuitry 22 of the given device).

Once calibration data has been gathered and stored in memory in controlcircuitry 22, raw compass readings (i.e., compass orientation vectorVraw) from compass 26 can be corrected with the calibration data in realtime to produce accurate, corrected compass readings (compassorientation vector Vcor). The corrected compass readings are correctedfor misalignment between compass 26 and electronic device housing 12.Real time calibration operations can be performed by retrieving thedevice-specific calibration data from the memory in control circuitry22. The calibration data may take the form of a calibration matrix R,sometimes referred to as a calibration rotation matrix that can beapplied to raw compass orientation data Vraw to produce correctedcompass readings Vcor, as shown in equation 1.Vcor=[R]Vraw  (1)

In equation 1, Vraw is a vector containing X, Y, and Z components of acompass orientation (compass reading) received from compass 26 withoutcorrection (i.e., a vector X, Y, Z in a Cartesian coordinate system).The correction matrix R may be a three-by-three rotation matrix thatrotates raw compass orientation vector Vraw to produce corrected compassreading vector Vcor. Because corrected compass reading Vcor has beencalibrated, the effects of misalignment between compass 26 and housing12 have been removed and Vcor can be used by applications (includingoperating system functions and other software) on device 10 such as anavigation map, a compass application, or other function in which theaccurate orientation between compass 26 and device 10 ensures accurateoperation of the application.

The amount of magnetic field 64 in each of dimensions X, Y, and Z thatis produced when operating each electrical component and the resultingimpact on compass readings from compass 26 in dimensions X, Y, and Z canbe characterized empirically using a reference device (sometimes calleda golden device or golden device under test) in which compass 26 hasbeen accurately mechanically aligned with housing 12 and horizontal axis72 or by using one or more reference devices in which the orientation ofcompass 26 relative to housing 12 has been measured and is thereforeknown. After aligning board 40 (and therefore the components and paths52 on board 40) with respect to housing 12 in the reference device toensure that compass 26 is aligned with housing 12 (or after measuringthe amount of misalignment between compass 26 and housing 12), controlcircuitry 22 (FIG. 2) may operate one or more of the electricalcomponents on printed circuit board 40 at one or more operating levels.As an example, control circuitry 22 may direct camera 28 to move itslens to an “infinity focus” position, an “intermediate focus” position,or a “minimum focus distance” position, control circuitry 22 may directradio-frequency transceiver 32 to perform a particular wireless function(e.g., to transmit or receive signals), flash 30 may be operated at oneor more illuminations levels, two or more electrical components may beoperated at respective levels, etc.

FIG. 5 is a graph of illustrative compass measurements of the type thatmay be made during calibration operations on a given device thatcontains a compass to be calibrated. In the example of FIG. 5, compassreadings are being collected in three different dimensions (e.g.,compass signal Sx in dimension X as shown in the upper trace of FIG. 5,compass signal Sy in dimension Y as shown in the middle trace of FIG. 5,and compass signal Sz in dimension Z as shown in the lower trace of FIG.5). During illustrative calibration operations C1 of FIG. 5, controlcircuitry 22 directs camera 28 to operate under three different focussettings: F1 (e.g., infinity focus), F2 (e.g., minimum focus distance),and F3 (a focus at an intermediate distance). During illustrativecalibration operations C2, control circuitry 22 directs a component suchas radio-frequency transceiver 32 or flash 30 to operate at a singlesetting. During other calibration operations, control circuitry 22directs one or more other components to operate at various settings.During these calibration operations, control circuitry 22 uses compass26 to gather compass readings. Comparison of this compass reading datafrom the compass in the given device to baseline data gathered from oneor more reference devices allows device-specific calibration data to begenerated. This device-specific calibration data can be generated aspart of a manufacturing test and/or during use of device 10 in the fieldby a user.

The compass readings obtained by compass 26 are affected by the magneticfields produced by the currents flowing in paths 52 and currents flowingwithin the electrical components in device 10 during calibrationoperations. For example, if a strong current is flowing in a path 52that is near to compass 26, the resulting strong magnetic field that isproduced will affect compass 26 strongly. If a weak current is flowingin path 52 and/or if path 52 is located far from compass 26 or isoriented relative to compass 26 in a way that produces a weak magneticfield at compass 26, compass 26 will be only weakly affected.

By comparing compass readings obtained during calibration in a givenelectronic device 10 that is being operated in a factory test or in thefield by a user to baseline compass readings obtained by a compass in areference device during reference device calibration operations(sometimes referred to as precalibration), the calibrating correctionsthat are to be used by the given electronic device (e.g., correctiverotation matrix R) may be calculated and stored in the given device.During subsequent operation of the given device, the device (e.g.,control circuitry 22) may use the calibration data (e.g., rotationmatrix R) to calibrate compass readings from the compass to correct formisalignment of the compass with respect to housing 12.

FIG. 6 is a flow chart of illustrative steps involved in calibrating andoperating electronic devices such as device 10 usinginternally-generated magnetic fields from operating electricalcomponents such as the electrical components on printed circuit board 40of device 10 of FIG. 4.

At step 80, setup operations (precalibration operations) may beperformed. During the operations of step 80, the compass in each of oneor more reference devices may be characterized over a variety ofelectronic component operating conditions. As an example, compassreadings in X, Y, and Z dimensions may be gathered by control circuitrywithin a reference device while electrical components are operated atvarious different levels. The reference device is a device in which theorientation of compass 26 is perfect (or nearly perfect) with respect tohousing 12 or is a device in which the orientation of compass 26relative to housing 12 has been measured. Precalibration operations maybe performed using an aligned compass in a reference device or, ifdesired, a representative set of reference devices may be tested (e.g.,a set of devices each having a compass with a different knownorientation relative to the electrical components and paths on printedcircuit board 40). By measuring compass readings from all of thedifferent reference devices in the set and correlating the compassorientations in the different devices with the resulting compassreadings in a database, the behavior of the compass in response toalignment variations and a variety of electrical component operatingconditions can be characterized. These characteristics can serve asbaseline compass data (i.e., compass readings as a function of knowncompass-to-housing orientation data and known electrical componentoperating conditions) for use in subsequent calibration operations.

The electrical components that are operated during the calibrationoperations of step 80 may include components such as a camera flash, acamera, a radio-frequency transceiver, and other electronic componentson a printed circuit board such as board 40 of FIG. 4 that is screwed tohousing 12 with screws 70 or that is otherwise well aligned with respectto housing 12. Because compass 26 in each reference device(s) is alsowell aligned with respect to housing 12 or is at least oriented at aknown angle with respect to housing 12, the compass readings that aretaken during the reference device calibration operations of step 80 canbe used to precisely characterize how compasses are affected (i.e., howmuch magnetic field is produced for each axis of a compass) under eachof the variety of different operating conditions and, if desired, avariety of different compass orientations. By knowing how referencedevices responds to different electrical component operations (i.e.,different current flows through the various paths 52 on board 40), thecompass operations of a given non-reference device can be calibrated tocorrect for misalignment between the compass and the housing in thegiven device. The compass readings that are obtained using referencesdevice may be stored in the reference devices and/or may be stored andanalyzed by external computing equipment (e.g., one or more computers ina network, etc.).

At step 82, the compass in a given electronic device 10 that is to becalibrated can be used to gather compass readings while one or moreelectrical components within the given electrical device are beingoperated. Control circuitry 22 may, for example, direct a camera tooperate at one or more different focus settings (operating levels) whilecompass readings are acquired, may direct a camera flash or transceiverto operate at one or more settings while compass readings are acquired,or may operate other components in a way that is known (from thebaseline data acquired during the precalibration operation of step 80)to produce magnetic fields that affect compass readings from 26 compassin a known way.

After gathering compass data for the given device at step 82, theacquired compass readings can be analyzed at step 84. Calibration may beperformed in a factory setting (e.g., during manufacturing while device10 is interfacing with external computing equipment) or may be performedin the field when device 10 is being operated by a user. The analysis ofstep 82 may be performed by external computing equipment whencalibration is being performed on the given device during manufacturingor may be performed by control circuitry 22 within device 10 (e.g.,during manufacturing calibration operations or during calibrationoperations in the field). During compass data analysis, the compassreadings that were acquired during step 82 when operating electricalcomponents on board 40 using a given set of settings can be compared tothe compass readings that were obtained when operating the sameelectrical components in the reference device(s) using the same set ofsettings. If, for example, the reference device compass measurements ofstep 80 were gathered when operating a camera at three different focuspoints, the compass readings of step 82 will be acquired when operatingthe camera in the given device at the same three focus points, so thatthe difference in compass readings at the three different focus pointscan be computed.

If there is no difference between the compass readings in a referencedevice with a perfectly aligned compass and the compass readings of step82, the compass in the given device is perfectly aligned with respect tohousing 12. If, however, the compass readings obtained during step 82 onthe given device differ from the compass readings obtained during step80 on s reference device with an aligned compass, a set of calibrationdata can be obtained by comparing the compass readings from step 82 tothe compass readings obtained during the operations of step 80. Thecompass data from step 80 may corresponding to readings from a set ofelectronic devices each of which has a compass that is aligned at adifferent known angle with respect to housing 12. The comparisons ofstep 84 may be used to compute a calibrating rotation matrix R.Calibration data such as calibration matrix R is specific to the givendevice and therefore serves as device-specific calibration data.

At step 86, calibration matrix R or other device-specific calibrationdata for the given device that gathered the compass data at step 82 canbe stored in the given device. For example, matrix R may be stored instorage within control circuitry 22.

At step 88, the given device for which compass data was gathered at step82 can be used by a user. For example, a user may launch and usesoftware such as a navigation application, a compass application, orother software that uses compass data from compass 26. During use ofdevice 10 in the field by a user, control circuitry 22 may use compass26 to gather raw compass data. Control circuitry 22 may then usedevice-specific compass data to calibrate the given device and therebycorrect compass 26 for misalignment between compass 26 and electronicdevice housing 12. For example, control circuitry 22 can calibrate rawcompass readings Vraw to produce calibrated compass readings Vcor bymultiplying raw compass readings Vraw by rotation matrix R, as shown inequation 1. Calibrated compass data Vcor can be used by applications indevice 10.

Compass 26 can be calibrated in a factory as part of a manufacturingprocess and/or compass 26 can be calibrated one or more times in thefield during use of device 10 by a user. As indicated by line 90, forexample, following calibration of compass data at step 88, processingcan loop back to step 82, so that additional compass data may beacquired (step 82), so that a new calibration matrix R can be computedand stored (steps 84 and 86), and so that raw data Vraw can be acquiredand corrected by applying rotation matrix R at step 88. Device 10 canloop through steps 82, 84, 86, and 88 periodically (e.g., once every dayor other time period), may perform calibration in response to changes inlocation, accelerometer output or other data indicating that device 10has been dropped and may therefore have caused compass 26 to becomemisaligned with respect to housing 12, or when other criteria have beensatisfied.

The foregoing is merely illustrative and various modifications can bemade by those skilled in the art without departing from the scope andspirit of the described embodiments. The foregoing embodiments may beimplemented individually or in any combination.

What is claimed is:
 1. A method of calibrating a first compass in afirst electronic device based on compass data generated by a secondcompass in a second electronic device, the method comprising: operatingan electronic component within the first electronic device to producemagnetic fields; with the first compass in the first electronic device,generating additional compass data in response to the magnetic fields;comparing the compass data and the additional compass data; and inresponse to determining that the compass data is different from theadditional compass data, generating compass calibration data with thefirst electronic device.
 2. The method defined in claim 1, furthercomprising: applying the compass calibration data to the additionalcompass data to produce calibrated compass data.
 3. The method definedin claim 2 wherein the electronic component is a camera and whereinapplying the compass calibration data comprises subtracting apredetermined value from the additional compass data to compensate foran interfering magnetic field produced by operating the camera.
 4. Themethod defined in claim 1 wherein generating the compass data comprisesgenerating the compass data in response to magnetic fields in a firstdimension, a second dimension, and a third dimension.
 5. The methoddefined in claim 1 wherein operating the electronic component comprisesoperating the electronic component in a first operational state, asecond operational state, and a third operational state.
 6. The methoddefined in claim 5 wherein generating the compass calibration datacomprises generating a first set of compass calibration data when theelectronic component is operated in the first operational state,generating a second set of compass calibration data when the electroniccomponent is operated in the second operational state, and generating athird set of compass calibration data when the electronic component isoperated in the third operational state.
 7. The method defined in claim1 wherein the first compass has an alignment within the first electronicdevice, wherein the second compass has a predetermined alignment withinthe second electronic device that is different than the alignment, andwherein the compass data and the additional compass data are differentdue to the difference between the alignment and the predeterminedalignment.
 8. The method defined in claim 7 wherein the compasscalibration data is configured to compensate for the difference betweenthe alignment and the predetermined alignment.
 9. The method defined inclaim 1 wherein the compass data is generated in response to additionalmagnetic fields produced by operating an additional electronic componentin the second electronic device.
 10. An electronic device comprising: ahousing; an electronic component within the housing, wherein operationof the electronic component produces magnetic fields; a compass withinthe housing, wherein the compass generates raw compass data based on themagnetic fields produced by the electronic component; and controlcircuitry within the housing that generates compass calibration databased on the raw compass data and applies the compass calibration datato the raw compass data to generated compensated compass data.
 11. Theelectronic device defined in claim 10 wherein the control circuitrycompares the raw compass data to compass readings generated by areference electronic device, wherein generating the compass calibrationdata comprises generating the compass calibration data based ondifferences between the compass readings generated by the referenceelectronic device and the raw compass data generated by the electronicdevice.
 12. The electronic device defined in claim 11 wherein anadditional compass that generates the compass readings has apredetermined alignment within the reference electronic device, whereinthe compass has an alignment within the electronic device that isdifferent than the predetermined alignment, and wherein the compasscalibration data compensates for differences between the compass dataand the compass readings due to the difference between the alignment andthe predetermined alignment.
 13. The electronic device defined in claim10 wherein the electronic component comprises a camera, whereinoperating the electronic component comprises adjusting the camera to atleast three different operating levels, and wherein generating thecompass calibration data comprises generating different compasscalibration data for each of the at least three different operatinglevels.
 14. The electronic device defined in claim 10 wherein theelectronic component comprises a radio-frequency transceiver, whereinoperating the electronic component comprises performing a plurality ofwireless functions with the radio-frequency transceiver and whereingenerating the compass calibration data comprises generating differentcompass calibration data for each of the different wireless functions.15. A method, comprising: controlling operation of an electricalcomponent mounted in an electronic device housing so that magneticfields are produced; while the magnetic fields are being produced,gathering compass readings of the magnetic fields with a compass in theelectronic device; and producing compass calibration data based on thegathered compass readings.
 16. The method defined in claim 15 whereinproducing the compass calibration data comprises producing the compasscalibration data based at least partly on compass data gathered in areference electronic device that includes a compass.
 17. The methoddefined in claim 16 wherein the compass data gathered in the referenceelectronic device comprises compass data gathered while producingmagnetic fields in the reference electronic device by adjusting a camerafocus and wherein producing the compass calibration data comprisesproducing the compass calibration data based at least partly on thecompass data gathered while producing the magnetic fields.
 18. Themethod defined in claim 16 wherein the compass data gathered in thereference electronic device comprises compass data gathered whileproducing magnetic fields in the reference electronic device byadjusting a camera flash and wherein producing the calibration datacomprises producing the calibration data based at least partly on thecompass data gathered while producing the magnetic fields.
 19. Themethod defined in claim 16 wherein the compass data gathered in thereference electronic device comprises compass data gathered whileproducing magnetic fields in the reference electronic device byadjusting a radio-frequency transceiver and wherein producing thecalibration data comprises producing the calibration data based at leastpartly on the compass data gathered while producing the magnetic fields.20. The method defined in claim 15 further comprising: applying thecompass calibration data to raw compass data generated by the compass togenerate calibrated compass data.
 21. The method defined in claim 15further comprising: comparing the compass readings to compass readingsgenerated by a reference electronic device, wherein producing thecompass calibration data comprises producing the compass calibrationdata based on differences between the compass readings generated by thereference device and the compass readings generated by the electronicdevice.